//
//  ForYouRecomdSubCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2017/12/18.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import "ForYouRecomdSubCell.h"

@interface ForYouRecomdSubCell ()
@property (weak, nonatomic) IBOutlet UIImageView *topImageView;
@property (weak, nonatomic) IBOutlet UILabel *topLabel;
@property (weak, nonatomic) IBOutlet UILabel *middleLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLable;
@property (weak, nonatomic) IBOutlet UILabel *lastLabel;

@end

@implementation ForYouRecomdSubCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    self.topLabel.font = MYFONT(12);
    
    self.middleLabel.font = MYFONT(14);
    self.middleLabel.textColor = darkGray;
    self.priceLable.font = MYFONT(15);
    self.priceLable.textColor = [UIColor redColor];
    
    
    self.lastLabel.attributedText = nil;
    // Initialization code
}

- (void)setSubModel:(MarketHSubModel *)subModel{
    _subModel = subModel;
    
    self.topLabel.text = _subModel.goods_name;
    
    self.middleLabel.text = _subModel.descrip;
    
    self.priceLable.text = [NSString stringWithFormat:@"%@P",_subModel.price];
    
    self.lastLabel.attributedText = [self attributedStrin:[NSString stringWithFormat:@"%@P",_subModel.promotion_price]];

    
    [self.topImageView sd_setImageWithURL:[NSURL URLWithString:_subModel.pic_cover_small] placeholderImage:nil];
    


    
    
}



- (NSMutableAttributedString *)attributedStrin:(NSString *)str{
    
    NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:str];
    
    [attr addAttribute:NSFontAttributeName value:MYFONT(14) range:NSMakeRange(0, str.length)];
    [attr addAttribute:NSForegroundColorAttributeName value:darkGray range:NSMakeRange(0, str.length)];
    [attr addAttribute:NSStrikethroughStyleAttributeName value:@1 range:NSMakeRange(0, str.length)];
    //    [attr addAttribute:NSKernAttributeName value:@(0.5f) range:NSMakeRange(0, str.length)];
    
    return attr;
}

@end
